#include<stdio.h>
#include<stdlib.h>
#include "dominion.h"


void testisGameOver(){

	struct gameState* gs;

	gs=newGame();

	int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse,
		           sea_hag, tribute, smithy};

	initializeGame(2, k, 1, gs);


	/**************************** TEST 1  ********************************/

	//if stack of Province cards is empty, the game ends
	gs->supplyCount[province] = 1;

	//if three supply pile are at 0, the game ends
	for(int i=0;i<25;i++){
		gs->supplyCount[i] = 1; //everything has one card should not be over
	}

	if(!isGameOver(gs)){
			printf("isGameOVer(): PASS when one of all cards are remaining.\n");
	}
	else{
			printf("isGameOVer(): FAIL when one of all cards are remaining.\n");
	}



	/**************************** TEST 2  ********************************/

	//if three supply pile are > than 0 but the province card stack is empty, the game still ends
	for(int i=0;i<25;i++){
		gs->supplyCount[i] = 1; //everything has one card
	}

	//if stack of Province cards is empty, the game ends
		gs->supplyCount[province] = 0;

	if(isGameOver(gs)){
			printf("isGameOVer(): PASS when one of all cards are remaining but Province are at 0.\n");
	}
	else{
			printf("isGameOVer(): FAIL when one of all cards are remaining but Province are at 0.\n");
	}

	/**************************** TEST 3  ********************************/

	//if stack of Province cards is not empty...
	gs->supplyCount[province] = 1;

	//...but if at least three supply pile are at 0, the game ends
	for(int i=0;i<25;i++){
		gs->supplyCount[i] = 1; //everything has one card should not be over
	}

	gs->supplyCount[0] = 0;//the three empty piles
	gs->supplyCount[1] = 0;
	gs->supplyCount[2] = 0;

	if(isGameOver(gs)){
			printf("isGameOVer(): PASS when three supply pile are at 0.\n");
	}
	else{
			printf("isGameOVer(): FAIL when three supply pile are at 0.\n");
	}


}


int main(int argc, char *argv[])
{

	testisGameOver();
    return 0;
}



